package wiki.xsx.jdbc;

/**
 * @Descript 查询条件类
 * @Author xsx
 * @Date 2017/11/11
 */
public class Condition {
    /**
     * SQL条件连接符:
     * AND 或 OR
     */
    private String joinKey;
    /**
     * 字段名称
     */
    private String fieldName;
    /**
     * 查询条件符号:
     * "=","!=","<>",">",">=","<","<=","LIKE","NOT LIKE","IN","NOT IN","IS NULL","IS NOT NULL","BETWEEN,AND"
     */
    private String symbol;
    /**
     * 查询条件值:
     * 当 symbol 为 "IS NULL" 或 "IS NOT NULL" 时,该值需设置为 null;
     * 当 symbol 为 "BETWEEN,AND" 时,该值需设置为 "value,value" 形式
     */
    private Object value;
    /**
     * 值类型:
     * 仅当symbol为 "IN" 或 "NOT IN"且为字符串条件时,需设置此值,并将该值设置为 DataType.STRING
     */
    private DataType valueType;

    public Condition(String joinKey, String fieldName, String symbol, Object value, DataType valueType) {
        this.joinKey = joinKey;
        this.fieldName = fieldName;
        this.symbol = symbol;
        this.value = value;
        this.valueType = valueType;
    }

    public Condition(String joinKey, String fieldName, String symbol, Object value) {
        this(joinKey, fieldName, symbol, value, DataType.NUMBER);
    }

    public String getJoinKey() {
        return joinKey;
    }

    public String getFieldName() {
        return fieldName;
    }

    public String getSymbol() {
        return symbol;
    }

    public Object getValue() {
        return value;
    }

    public DataType getValueType() {
        return valueType;
    }
}
